package com.wyw.learning.thread.collections.predecessor;

import java.util.HashMap;
import java.util.Map;

/**
 * 演示Map的基本用法
 *  为什么HashMap是线程不安全的？
 *      同时put碰撞导致数据丢失
 *      同时put扩容导致数据丢失
 *      死循环造成CPU100%（主要存在Java7中）
 *          产生原因：在多个线程扩容时会导致链表的死循环
 *          可见：https://coolshell.cn/articles/9606.html
 *          https://www.jianshu.com/p/1e9cf0ac07f4
 *          https://www.jianshu.com/p/619a8efcf589
 *          https://blog.csdn.net/loveliness_peri/article/details/81092360
 *          https://cloud.tencent.com/developer/article/1120823
 *          https://www.cnblogs.com/developer_chan/p/10450908.html
 *
 * @author Mr Wu    yewen.wu.china@gmail.com
 * <p>
 * Update History:
 * Author        Time            Content
 */
public class MapDemo {
    public static void main(String[] args) {
        Map<String, Integer> map = new HashMap<>();
        System.out.println(map.isEmpty());
        map.put("东哥", 38);
        map.put("西哥", 28);
        System.out.println(map.keySet());
        System.out.println(map.get("西哥"));
        System.out.println(map.size());
        System.out.println(map.containsKey("东哥"));
        map.remove("东哥");
        System.out.println(map.containsKey("东哥"));

    }
}
